import request from "@/utils/request";

// cn下的人员列表 分页
export const pageList = query => {
  return request({
    url: "/ad/person/pageList",
    method: "get",
    params: query
  });
};
// 搜索人
export const searchPersonPage = query => {
  return request({
    url: "/ad/person/searchPersonPage",
    method: "get",
    params: query
  });
};
//人员信息
export const info = sAMAcountName => {
  return request({
    url: `/ad/person/${sAMAcountName}/info`,
    method: "get"
  });
};

//人员计算机
export const computers = sAMAcountName => {
  return request({
    url: `/ad/person/${sAMAcountName}/computers`,
    method: "get"
  });
};

//人员私人计算机列表
export const personalComputer = (sAMAcountName, query) => {
  return request({
    url: `/ad/person/${sAMAcountName}/personalComputers`,
    method: "get",
    params: query
  });
};

//人员私人计算机列表
export const publicComputer = (sAMAcountName, query) => {
  return request({
    url: `/ad/person/${sAMAcountName}/publicComputers`,
    method: "get",
    params: query
  });
};

//绑定私人计算机
export const bindPersonalComputer = (sAMAcountName, computerAccount) => {
  return request({
    url: `/ad/person/${sAMAcountName}/bindPersonalComputer`,
    method: "post",
    params: { computerAccount }
  });
};
//绑定私人计算机
export const bindPublicComputer = (sAMAcountName, computerAccount) => {
  return request({
    url: `/ad/person/${sAMAcountName}/bindPublicComputer`,
    method: "post",
    params: { computerAccount }
  });
};

//解绑计算机
export const unBindPublicComputer = (
  sAMAcountName,
  computerAccount,
  computerType = "personal"
) => {
  return request({
    url: `/ad/person/${sAMAcountName}/unbindComputer`,
    method: "post",
    params: { computerAccount, computerType }
  });
};
// 导出
export const exportExcel = query => {
  return request({
    url: "/ad/person/exportExcel",
    method: "post",
    params: query,
    responseType: "blob"
  });
};
// 导入
export const importExcel = query => {

  // return request.post({
  //   url: "/ad/person/importPersonTemplate",
  //   method: "post",
  //   params: query,
  //   headers: {
  //     "Content-Type": "multipart/form-data"
  //   },
  
  // });
   return request.post(
     "/ad/person/importPersonTemplate",
     query

  );
};

export const importComputerFromClipboard = data => {
  return request({
    url: "/ad/person/importComputerFromClipboard",
    method: "post",
    data
  });
};
export default {
  pageList,
  info,
  computers,
  personalComputer,
  publicComputer,
  bindPersonalComputer,
  bindPublicComputer,
  unBindPublicComputer,
  exportExcel,
  importExcel,
  importComputerFromClipboard,
  searchPersonPage
};
